-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Account for KVS collisions in NVM identifiers #9489
Conversation
Potential Conflict WarningThis pull request has changes that overlap with branches below. You might want to check in with the other
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update the summary with:
- if using stl with heap usage, why this is ok (is this temporary or ok for long term?)
- how are the new global variables persisted across reboot? What makes the method work consistently?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* how are the new global variables persisted across reboot? What makes the method work consistently?
++ What @andreilitvin said.
Three things:
- kvs and kvs_ids have to be recreated at boot, but aren't
- it is impossible to recreate kvs at boot though because the string keys can't be recovered from the uint8 kv id hash
- overwriting a matching key with PUT is no longer possible; put with equal key isn't a key collision; this should be legal
I believe a similar key collision problem may have been solved here: #7472. Suggest using that as a possible guide to a workable solution.
I think the approach of #7472 is not going to work, because it does static string -> key ID mapping. That implies no dynamic keys. For instance, to have working storage for multiple fabrics, it would means storing ALL fabrics in 1 key with a single name, rather than being able to store one key per fabric, dynamically "generated" (e.g. Overall, we are starting to arrive at a new choke point in storage examples for platforms that do not arbitrarily support key mapping. |
@tcarmelveilleux and I discussed offline and in fact #7472 does work (albeit only for keys <= 32 chars long). It's using two separate non-volatile spaces: one for keys and one for values. This is a variant of a table of contents. The larger story is that we are dissatisfied with the sdk's current kvstore interface. However, for the purposes here of this PR (#9489), you just need to find some way to persist the table of contents. #7472 shows one possible approach. |
@doru91 - this should be ready to merge after the comments from Michael |
PR #9489: Size comparison from ee7682d to 060b63b Increases above 0.2%:
Increases (3 builds for k32w)
Full report (8 builds for k32w, p6, qpg)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Key collision will likely brick the system with abort().
PR #9489: Size comparison from 3295ca0 to f5b84c8 Full report (2 builds for esp32)
|
PR #9489: Size comparison from 3f67119 to 6724e07 Increases above 0.2%:
Increases (3 builds for k32w)
Full report (31 builds for efr32, k32w, linux, mbed, nrfconnect, telink)
|
Solved Michael's comments, the ESP32 build fails independently of the changes from this PR. |
PR #9489: Size comparison from d45cfaa to dec7719 Increases above 0.2%:
Increases (3 builds for k32w)
Full report (38 builds for efr32, esp32, k32w, linux, mbed, nrfconnect, p6, qpg, telink)
|
Old implementation was not taking into account collissions. The new implementation keeps an unorderded hash having as keys the matter string keys and as values the key ids used as PDM identifiers. Used key ids are saved in a list which is updated at each Put/Delete operation. Also, in order to be able to restore from flash the unordered hash, the matter string keys are saved in flash. Signed-off-by: Doru Gucea <[email protected]>
Signed-off-by: Doru Gucea <[email protected]>
Co-authored-by: Restyled.io <[email protected]> Signed-off-by: Doru Gucea <[email protected]>
Co-authored-by: Restyled.io <[email protected]> Signed-off-by: Doru Gucea <[email protected]>
PR #9489: Size comparison from d45cfaa to 06014a7 Decreases (1 build for esp32)
Full report (13 builds for esp32, linux, qpg)
|
* Fix KVS implementation Old implementation was not taking into account collissions. The new implementation keeps an unorderded hash having as keys the matter string keys and as values the key ids used as PDM identifiers. Used key ids are saved in a list which is updated at each Put/Delete operation. Also, in order to be able to restore from flash the unordered hash, the matter string keys are saved in flash. Signed-off-by: Doru Gucea <[email protected]> * Fixes after review Signed-off-by: Doru Gucea <[email protected]> * Restyled by clang-format (project-chip#11433) Co-authored-by: Restyled.io <[email protected]> Signed-off-by: Doru Gucea <[email protected]> * Restyled by clang-format (project-chip#11464) Co-authored-by: Restyled.io <[email protected]> Signed-off-by: Doru Gucea <[email protected]> Co-authored-by: restyled-io[bot] <32688539+restyled-io[bot]@users.noreply.github.com> Co-authored-by: Restyled.io <[email protected]>
Problem
Change overview
Testing